<script>
const ws = new WeakSet()
class Foo{
  constructor() { ws.add(this)  }
  method() {
    if (!ws.has(this) ) {
      throw new Error('调用的上下文错误')
    }
    console.log(this, 'method')
  }
}
function fn2() {
  // 'use strict'
  console.log(this, 'fn2')}
const foo = new Foo()
foo.method() // foo 'method'
const bar = {name:'bar', method: foo.method}
const fn = foo.method
// fn() // undefined 'method'
// fn2() // window fn2
bar.method() // bar 'method'


</script>